import { createLogger, createStore } from 'vuex'


export interface IListItem {
  task: string,
  time: string,
  id: string | number,
}
export interface Istate {
  list: IListItem[]
}
let state: Istate = {
  list: [{
    task: '测试',
    time: '2022-03-04 43:34:34',
    id: 123
  }]
}
let store = createStore({
  plugins: [createLogger()],
  state: state,
  mutations: {
    add(state: Istate, obj: IListItem) {
      state.list.unshift(obj)
    },
    remove(state, id: string | number) {
      state.list = state.list.filter(item => item.id != id)
    }
  }
})

export default store